package com.worthtech.billportal.bean;

import java.io.UnsupportedEncodingException;

import com.worthtech.billportal.util.Util;

public class WLout {
	private String sysno;
	private String username;
	private String phone;
	private String goods;
	private String amt;
	
	public String getAmt() {
		return amt;
	}
	public void setAmt(String amt) {
		this.amt = amt;
	}
	public String format(String old,int length){
		String n = old;
//		System.out.println("1["+n+"]leng="+length);
		if(n ==null){
			n="";
		}
		String tmp="";
//		System.out.println("n="+n.length());
		try {
			for(int i=0;i<length-n.getBytes("gb2312").length;i++){
				tmp+=" ";
			}
		} catch (UnsupportedEncodingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
//		System.out.println("2["+n+"]");
		return n+tmp;
	}
	public String getSysno() {
		return sysno;
	}
	public void setSysno(String sysno) {
		this.sysno = sysno;
	}
	public String getUsername() {
		return username;
	}
	public void setUsername(String username) {
		this.username = username;
	}
	public String getPhone() {
		return phone;
	}
	public void setPhone(String phone) {
		this.phone = phone;
	}
	public String getGoods() {
		return goods;
	}
	public void setGoods(String goods) {
		this.goods = goods;
	}
	
	public byte []  getall(){
		String str = "";
		str += format(sysno,40);
		str += format(username,40);
		str += format(phone,20);
		str += format(goods,80);
		byte[] b;
		try {
			b = str.getBytes("gb2312");
		
		byte [] c =new byte[7];
		
		c[0] = (byte)Integer.parseInt(amt.substring(0,2),16);
		c[1] = (byte)Integer.parseInt(amt.substring(2,4),16);
		c[2] = (byte)Integer.parseInt(amt.substring(4,6),16);
		c[3] = (byte)Integer.parseInt(amt.substring(6,8),16);
		c[4] = (byte)Integer.parseInt(amt.substring(8,10),16);
		c[5] = (byte)Integer.parseInt(amt.substring(10,12),16);
		c[6] = 0x03;
		return Util.arraycat(b,c) ;
		} catch (UnsupportedEncodingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return null;
		}
	}
}
